package com.fivestar.finance.app.injector.module;

import android.content.Context;

import com.fivestar.finance.app.greendao.DaoMaster;
import com.fivestar.finance.app.greendao.DaoSession;
import com.fivestar.finance.app.greendao.UserResponseDao;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * 简要描述
 *
 *  @author Derek.Kidd
 * @version V1.0.0
 * @date 2016/8/24 14:47
 */
@Module
public class DBModule {

    @Provides
    @Singleton
    DaoMaster.DevOpenHelper provideDevOpenHelper(Context context) {
        return new DaoMaster.DevOpenHelper(context, "app.db", null);
    }

    @Provides
    @Singleton
    DaoMaster provideDaoMaster(DaoMaster.DevOpenHelper helper) {
        return new DaoMaster(helper.getWritableDatabase());
    }

    @Provides
    @Singleton
    DaoSession provideDaoSession(DaoMaster master) {
        return master.newSession();
    }



    @Provides
    @Singleton
    UserResponseDao getUserResponseDao(DaoSession session) {
        return session.getUserResponseDao();
    }


//
//    @Provides
//    @Singleton
//    ImageCacheDao getImageCache(DaoSession session) {
//        return session.getImageCacheDao();
//    }
}
